package com.qezhhnjy.mall.coupon.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qezhhnjy.mall.common.entity.coupon.MemberPrice;
import com.qezhhnjy.mall.common.http.BaseResult;
import com.qezhhnjy.mall.coupon.service.MemberPriceService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 商品会员价格 前端控制器
 * </p>
 *
 * @author qezhhnjy
 * @since 2021-06-27
 */
@RestController
@Api(tags = "商品会员价格接口")
@Slf4j
@RequestMapping("/member-price")
public class MemberPriceController {
    @Resource
    private MemberPriceService memberPriceService;

    @GetMapping("/get")
    @Operation(summary = "根据id获取商品会员价格信息")
    public BaseResult<MemberPrice> get(Long id) {
        MemberPrice memberPrice = memberPriceService.getById(id);
        return BaseResult.success(memberPrice);
    }

    @PostMapping("/save")
    @Operation(summary = "新增商品会员价格信息")
    public BaseResult<MemberPrice> save(@RequestBody MemberPrice memberPrice) {
        memberPriceService.save(memberPrice);
        return BaseResult.success(memberPrice);
    }

    @PutMapping("/update")
    @Operation(summary = "更新商品会员价格信息")
    public BaseResult<MemberPrice> update(@RequestBody MemberPrice memberPrice) {
        memberPriceService.updateById(memberPrice);
        return BaseResult.success(memberPrice);
    }

    @PostMapping("/page")
    @Operation(summary = "分页获取商品会员价格信息")
    public BaseResult<Page<MemberPrice>> page(@RequestBody Page<MemberPrice> page) {
        memberPriceService.page(page);
        return BaseResult.success(page);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "根据id删除商品会员价格信息")
    public BaseResult<Long> delete(Long id) {
        memberPriceService.removeById(id);
        return BaseResult.success(id);
    }
}

